<?php

use think\migration\Migrator;
use think\migration\db\Column;

class StoreSalesmanOrder extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('store_salesman_order', ['comment' => '业务员订单表']);
        $table->addColumn('store_user_id', 'integer', ['comment' => '业务员id', 'limit' => 11, 'default' => 0])
            ->addColumn('company_id', 'integer', ['comment' => '公司id', 'limit' => 11, 'default' => 0])
            ->addColumn('no', 'string', ['comment' => '订单编号', 'limit' => 50, 'default' => ''])
            ->addColumn('pay_type', 'integer', ['comment' => '支付类型 1:支付宝,2:微信,3:账期,4:余额,5:大额转账,6:银行卡支付,7:线下支付,8:其他', 'limit' => 11, 'default' => 1])
            ->addColumn('order_status', 'integer', ['comment' => '订单状态(1:待支付,2:待发货,3:待收货,4:已完成,5:已取消)', 'limit' => 11, 'default' => 1])
            ->addColumn('buyer_remark', 'string', ['comment' => '买家备注', 'limit' => 255, 'default' => ''])
            ->addColumn('voucher', 'string', ['comment' => '凭证', 'limit' => 255, 'default' => ''])
            ->addColumn('channel', 'integer', ['comment' => '订单来源1:oms 2:saas', 'limit' => 11, 'default' => 1])
            ->addColumn('amount', 'decimal', ['comment' => '订单金额', 'precision' => 10, 'scale' => 2, 'default' => 0.00])
            ->addColumn('pay_amount', 'decimal', ['comment' => '支付金额', 'precision' => 10, 'scale' => 2, 'default' => 0.00])
            ->addColumn('create_time', 'integer', ['comment' => '创建时间', 'limit' => 11, 'default' => 0])
            ->addColumn('update_time', 'integer', ['comment' => '更新时间', 'limit' => 11, 'default' => 0])
            ->addColumn('delete_time', 'integer', ['comment' => '删除时间', 'limit' => 11, 'default' => 0])
            ->addIndex(['store_user_id'], ['name' => 'idx_store_user_id'])
            ->addIndex(['company_id'], ['name' => 'idx_company_id'])
            ->create();
    }
}
